#!/usr/bin/env python
# coding=utf-8
# __author__ = 'Yunchao Ling'

from xml.etree import ElementTree as ET
import sys


def validate(file):
    try:
        ET.parse(file)
        print file + ' is a valid xml'
    except Exception, e:
        print file + ' a invalid xml'
        print file + ' Possible reasons：', e


if __name__ == "__main__":

    start = int(sys.argv[1])
    dur = int(sys.argv[2])

    for i in xrange(start, start + dur, 10000):
        filename = "pubmed_" + str(i) + "_" + str(i + 10000 - 1) + ".xml"
        validate(filename)
